<template>
  <div class="app-container">
    <!-- <div class="wise-crud">
      <div class="table-show">
        <div class="operation-block">
          <el-row class="oper-btn" :gutter="10">
            <el-col :span="16">
              <el-button type="primary" @click="handleAdd()"><i class="el-icon-plus" />添加</el-button>
            </el-col>
          </el-row>
        </div>
        <el-table :key="symbolKey" :data="tableData" border highlight-current-row row-key="id" lazy :load="load"
          :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
          <el-table-column label="序号" type="index" width="100" />
          <el-table-column label="名称" prop="name" />
          <el-table-column :label="$t('table.actions')" align="center" width="250">
            <template slot-scope="scope">
              <el-button v-if="scope.row.level === 1" size="mini" type="info" @click="handleView(scope.row)">
                {{ $t("table.see") }}</el-button>
              <el-button v-if="scope.row.level === 1" size="mini" type="success" @click="handleEdit(scope.row)">
                {{ $t("table.edit") }}</el-button>
              <el-button v-if="scope.row.level === 1" size="mini" type="danger" @click="handleDelete(scope.row)">
                {{ $t("table.delete") }}</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="page-block">
          <pagination :background="true" layout="total,prev, pager, next" :total="ts" :page.sync="page.p"
            :limit.sync="page.ps" @pagination="getTableData" />
        </div>
      </div>
      <el-dialog ref="drawer" :title="title" :visible.sync="drawer" append-to-body destroy-on-close>
        <div v-if="drawer" class="draw-body">
          <wise-form :columns="formItems" :loading="loading" :old-object="object" @on-submit="submitHandle" />
        </div>
      </el-dialog>
      <el-dialog ref="viewDrawer" title="查看" :visible.sync="viewDrawer" append-to-body close-on-press-escape
        destroy-on-close>
        <div class="draw-body">
          <wise-view :columns="viewItems" :object="object" />
        </div>
      </el-dialog>
    </div> -->
    <wise-crud ref="wise-crud" :urls="urls" :fields="fields" :handle="handle" />
  </div>
</template>

<script>
  import WiseCrud from '@/components/Crud/wiseCrud'
  export default {
    name: 'PositionManage',
    components: {
      WiseCrud
    },
    data() {
      return {
        handle: ['add'],
        urls: {
          list: '/api/v1/welder-sbtx-second/hot-approval-comb/list',
          add: '/api/v1/welder-sbtx-second/hot-approval-comb/create',
          show: '/api/v1/welder-sbtx-second/hot-approval-comb/show/',
          update: '/api/v1/welder-sbtx-second/hot-approval-comb/update/',
          delete: '/api/v1/welder-sbtx-second/hot-approval-comb/remove/'
        },
        symbolKey: '',
        object: {},
        loading: false,
        tableData: [],
        formItems: [],
        viewItems: [],
        drawer: false,
        title: '',
        viewDrawer: false,
        ts: 0,
        page: {
          p: 1,
          ps: 20
        },
        fields: [{
            label: '序号',
            type: 'index',
            use: ['table']
          },
          {
            label: '审批名称',
            prop: 'name',
            type: 'text',
            labelWidth: '190px',
            rules: [{
              required: true,
              message: '请输入审批名称',
              trigger: 'blur'
            }],
            placeholder: '请输入审批名称',
            use: ['add', 'table', 'view', 'edit']
          },
          {
            label: '生产调度部门',
            prop: 'productionUserInfo',
            labelWidth: '190px',
            type: 'render',
            viewRender: (h, item, object) => {
              let divHtml = ""
              if (object.productionUserInfo.status == 0) {
                divHtml += object.productionUserInfo.username
              } else {
                divHtml += object.productionUserInfo.username
              }
              return h('div', divHtml)
              //return h('div', object.facilityUserInfo ? object.facilityUserInfo.username : '')
            },
            use: ['view']
          }, {
            label: '生产调度部门',
            prop: 'entSpaceObj',
            type: 'select',
            labelWidth: '190px',
            url: '/api/v1/welder-uac-second/user-information-comb/get-ent-member',
            labelKey: 'username',
            valueKey: 'userId',
            objKeys: [{
              field: 'productionAdminUserId',
              operator: 'EQUALS',
              key: 'userId'
            }],
            rules: [{
              required: true,
              message: '请选择人员',
              trigger: 'change'
            }],
            use: ['add', 'edit']
          }, {
            label: '资产设施管理部门',
            prop: 'assetsUserInfo',
            labelWidth: '190px',
            type: 'render',
            viewRender: (h, item, object) => {
              let divHtml = ""
              if (object.assetsUserInfo.status == 0) {
                divHtml += object.assetsUserInfo.username
              } else {
                divHtml += object.assetsUserInfo.username
              }
              return h('div', divHtml)
              //return h('div', object.facilityUserInfo ? object.facilityUserInfo.username : '')
            },
            use: ['view']
          }, {
            label: '资产设施管理部门',
            prop: 'entSpaceObj1',
            type: 'select',
            labelWidth: '190px',
            url: '/api/v1/welder-uac-second/user-information-comb/get-ent-member',
            labelKey: 'username',
            valueKey: 'userId',
            objKeys: [{
              field: 'assetsAdminUserId',
              operator: 'EQUALS',
              key: 'userId'
            }],
            rules: [{
              required: true,
              message: '请选择人员',
              trigger: 'change'
            }],
            use: ['add', 'edit']
          }, {
            label: '安全监管部门',
            prop: 'safetyUserInfo',
            labelWidth: '190px',
            type: 'render',
            viewRender: (h, item, object) => {
              let divHtml = ""
              if (object.safetyUserInfo.status == 0) {
                divHtml += object.safetyUserInfo.username
              } else {
                divHtml += object.safetyUserInfo.username
              }
              return h('div', divHtml)
              //return h('div', object.facilityUserInfo ? object.facilityUserInfo.username : '')
            },
            use: ['view']
          }, {
            label: '安全监管部门',
            prop: 'entSpaceObj2',
            type: 'select',
            labelWidth: '190px',
            url: '/api/v1/welder-uac-second/user-information-comb/get-ent-member',
            labelKey: 'username',
            valueKey: 'userId',
            objKeys: [{
              field: 'safetyAdminUserId',
              operator: 'EQUALS',
              key: 'userId'
            }],
            rules: [{
              required: true,
              message: '请选择人员',
              trigger: 'change'
            }],
            use: ['add', 'edit']
          },
          {
            prop: 'facilityUserInfo',
            label: '资产设施管理部门负责人',
            labelWidth: '190px',
            type: 'render',
            viewRender: (h, item, object) => {
              let divHtml = ""
              if (object.facilityUserInfo.status == 0) {
                divHtml += object.facilityUserInfo.username
              } else {
                divHtml += object.facilityUserInfo.username
              }
              return h('div', divHtml)
              //return h('div', object.facilityUserInfo ? object.facilityUserInfo.username : '')
            },
            use: ['view']
          }, {
            label: '资产设施管理部门负责人',
            prop: 'entSpaceObj3',
            type: 'select',
            labelWidth: '190px',
            url: '/api/v1/welder-uac-second/user-information-comb/get-ent-member',
            labelKey: 'username',
            valueKey: 'userId',
            objKeys: [{
              field: 'facilityAdminUserId',
              operator: 'EQUALS',
              key: 'userId'
            }],
            rules: [{
              required: true,
              message: '请选择人员',
              trigger: 'change'
            }],
            use: ['add', 'edit']
          }, {
            label: '操作',
            type: 'handle',
            use: ['table'],
            handle: ['edit', 'view', 'delete']
          }
        ]
      }
    },
    computed: {
      handle() {
        return ['add']
      },
    },
    mounted() {},
    methods: {}
  }
</script>

<style scoped>
</style>